<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class MessController extends Controller
{
   public function Say(){
       $id = session('user_id');
       $res = DB::table('users')->where('id',$id)->get();
       //dd($res);
       return view('home.mess',['res'=>$res]);
   }

   //上传意见
    public function Show(Request $request){
       $uid = $request->id;
       $username = $request->nickname;
       $email = $request->email;
       $msg = $request->msg;
       $url = $request->refer_url;
       $res =DB::table('mess')->insert(['user_id'=>$uid,'username'=>$username,'email'=>$email,'content'=>$msg,'url'=>$url]);
       //dd($request->all());
        if ($res != false){
            return redirect('home/homepage');
        }
    }
    //回复意见
    public function Getmess(){
        $res = DB::table('mess')->where('flag',1)->get();
//        dd($res);
        return view('home.getmess',['res'=>$res]);
    }
}
